<%@ page language="java" contentType="text/html; charset=utf-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<html>
<head>
<link href="${ctx}/styles/extremetable/extremecomponents.css" type="text/css" rel="stylesheet" />
<link href="${ctx}/styles/extremetable/style.css" type="text/css" rel="stylesheet" />
<link href="${ctx}/styles/listTable.css" rel="stylesheet" type="text/css">
<link href="${ctx}/styles/grid.css" rel="stylesheet" type="text/css">

<script language="JavaScript" type="text/javascript" src="${ctx}/scripts/global.js"></script>
<script language="JavaScript"  src="${ctx}/scripts/show.js"></script>
<script language="JavaScript"  src="${ctx}/scripts/public.js"></script>
<script type="text/javascript" src="${ctx}/scripts/common/prototype.js"></script>
<script language="JavaScript" type="text/javascript" src="${ctx}/scripts/rightmenu2.js"></script>
<script language="JavaScript" type="text/javascript" src="${ctx}/scripts/extremetable/extremecomponents.js"></script>
<script language="JavaScript" type="text/javascript" src="${ctx}/scripts/common.js"></script>
<script language="JavaScript" type="text/javascript" src="${ctx}/scripts/ajaxException.js"></script>

<script type="text/javascript">
 	function resize(){
		parent.window.document.all('residentFrame').style.height=document.body.scrollHeight;
	}
	var customerType = null;
	var customerId = null;
	var houseId = null;
	var houseNumber = null;
	var participantTypeCode=null;

	function openIn(){
		if(!allowOpen()){
			Alert('请选择一条记录');
			return;
		}
		var validationURL = "${ctx}/customer_customerAction.do?method=validationAllowMoveIn";
		var params = "houseId=" + houseId + "&clientId=" + customerId;
		sendAjaxRequest(validationURL,params,function(result){
			var obj = result.responseText;
			ajaxSubmitException(obj);
			if(obj=="pass"){
				var url = "${ctx}/customer_customerAction.do?method=initLiveIn&customerType=" + customerType + "&houseNumber=" + houseNumber;
				top.windowOpen(url,"liveIn","入住",250,450,false,"liveIn");
			}else{
				Alert( "房间" + obj + "入住后,还没搬出,请先搬出");
			}
		});

	}
	function openOut(){
		if(!allowOpen()){
			Alert('请选择一条记录');
			return;
		}
		var url = "${ctx}/customer_customerAction.do?method=initMoveOut&customerType=" + customerType + "&houseNumber=" + houseNumber;
		top.windowOpen(url,"moveOut","搬出",250,450,false,"liveIn");
	}
	/***判断是否允许打开页面****/
	function allowOpen(){
		if(customerType == null)return false;
		return true;
	}
	function setVar(_customerId,_houseId,_customerType,_houseNumber){
		houseId = _houseId;
		customerId = _customerId;
		parent.setVar(_customerId,_houseId);
		setCustomerType(_customerType,_houseNumber);
	}
	function setCustomerType(_customerType,_houseNumber){
		if(_customerType.indexOf("业主") != -1){
			customerType = "owner";
		}
		else if(_customerType.indexOf("租户") != -1){
			customerType = "lessee";
			houseNumber = _houseNumber;
		}
		if(_customerType.indexOf("个人") != -1)
			participantTypeCode = '001';
		else if(_customerType.indexOf("企业") != -1)
			participantTypeCode = '002';
	}

	/*
	When you double-click a record, the judgement of the types of customers,
	and trigger events, a new pop-up window, to see more details.
	*/
	function openDetail(participantId){
		var url = null;
		if(customerType=='owner'){//owner
			url = "${ctx}/customer_ownerAction.do?method=initOwnerDetailMain&curParticipantTypeCode=" + participantTypeCode+"&curParticipantId="+participantId;
			top.windowOpen(url,"ownerDetail","业主详细信息",610,900,true,"ownerDetail");
		}else if(customerType=='lessee'){
			url = "${ctx}/customer_lesseeAction.do?method=initLesseeDetailMain&participantTypeCode=" + participantTypeCode+"&participantId="+participantId;
			top.windowOpen(url,"lesseeDetail","租户详细信息",610,900,true,"lesseeDetail");
		}else{
			Alert("请选择一条记录！");
		}
	}
</script>

</head>
<body onload="resize();">
<ec:ceTable items="residentList"
	action="${ctx}/customer_customerAction.do?method=searchResident"
	var="varItem"
	view="pmsview"
	styleClass="gridData2"
	rowsDisplayed="12" >

	<ec:ceRow styleClass="grid"
			  onContextMenu="return ShowContextMenu(event,'quick_rightmenu')"
			  onclick="setVar('${varItem.customerID}','${varItem.houseId}','${varItem.customerType}','${varItem.houseNumber}');"
			  ondblclick="setVar('${varItem.customerID}','${varItem.houseId}','${varItem.customerType}','${varItem.houseNumber}');openDetail('${varItem.participantId}');">
		<ec:ceColumn headerCell="pmsHeadrCell" title="房号" property="houseNumber" width="9%" sortable="true"/>
		<ec:ceColumn headerCell="pmsHeadrCell" title="姓名" property="customerName" width="9%" sortable="true"/>
		<ec:ceColumn headerCell="pmsHeadrCell" title="住户类型" property="customerType" width="8%" />
		<ec:ceColumn headerCell="pmsHeadrCell" title="入住日期" property="inDate" width="12%" sortable="true"/>
		<ec:ceColumn headerCell="pmsHeadrCell" title="搬出日期" property="outDate" width="12%" sortable="true"/>
		<ec:ceColumn headerCell="pmsHeadrCell" title="证件类型" property="idCode" width="9%" />
		<ec:ceColumn headerCell="pmsHeadrCell" title="证件号码" property="idNO" width="8%" />
		<ec:ceColumn headerCell="pmsHeadrCell" title="联系电话" property="telephone" width="9%"/>
	</ec:ceRow>
</ec:ceTable>
<!--------------menu01------------------------->
<div id="quick_rightmenu" style="display:none;" oncontextmenu="return false" class="quick_rightmenu" onMouseOver="" onMouseOut="">
<table width="100%" border="0" cellpadding="1" cellspacing="0" class="grid_quickMenu_bg">
          <pms:AuthTag authName="customer_customerAction.do?method=initLiveIn">
          <tr>
          <td class="quickMenu_toolbarico"><a href="#"  onClick="openIn();" onFocus="this.blur()"><img src="${ctx}/images/door_in.gif" border="0" align="absbottom" alt="入住"/>&nbsp;入住</a></td>
          </tr>
          </pms:AuthTag>
          <pms:AuthTag authName="customer_customerAction.do?method=initMoveOut">
		  <tr>
          <td class="quickMenu_toolbarico"><a href="#"  onClick="openOut();" onFocus="this.blur()"><img src="${ctx}/images/door_out.gif" border="0" align="absbottom" alt="搬出"/>&nbsp;搬出</a></td>
          </tr>
           </pms:AuthTag>
      </table></td>
    </tr>
  </table>
</div>
</body>
</html>